<?php
/**
 *  The constructor implementation using config
 *
 */
class Yz_Descriptor_Config
    extends Yz_Descriptor_Abstract
    implements Yz_Descriptor_Interface
{

    /**
     *  Array [name => object Yz_Property_*]
     *  @var array
     */
    protected $properties = array();

    /**
     *  @param Yz_Config_Interface with the following entries:
     *      'property' (hash, required) : the configuration of properties
     */
    public function __construct( Yz_Config_Interface $config )
    {
        debug();
        foreach ($config as $propName => $propConfig) {
            // TODO what if $propConfig is not a config, or has no type
            debug("Prop<$propName>=$propConfig->type");
            $type = $propConfig->fetchString("type");
            // TODO resolve class using module
            $propClass = 'Yz_Property_' . ucfirst($type);
            $this->properties[$propName] = new $propClass($propName,$propConfig);
        }
    }

}
